<!-- 含封面的文章展示 -->
<template>
  <div id="article-item-v1">
    <div class="cover">
      <img :src="props.articleInfo.cover" alt="" />
    </div>
    <div class="content">
      <div class="title">
        <a :href="'/article/' + props.articleInfo._id" target="_blank">
          {{ props.articleInfo.title }}</a
        >
      </div>
      <div class="des">
        {{ props.articleInfo.des }}
      </div>
      <div class="time" v-format-time="'YYYY-MM-DD'">
        {{ props.articleInfo.time }}
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { defineProps } from 'vue'
import type { ArticleListDataTypes } from '@/server/client/api_article'

interface Props {
  articleInfo: ArticleListDataTypes
}

const props = defineProps<Props>()
</script>

<style scoped lang="less">
#article-item-v1 {
  .cover {
    width: 580px;
    height: 290px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .content {
    background-color: #fafafa;
    width: 580px;
    height: 150px;
    box-sizing: border-box;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .title {
      color: #333;
      font-size: 16px;
      a {
        color: #333;
      }
    }
    .des {
      margin-top: 14px;
      color: #878787;
      font-size: 14px;
      height: 44px;
      line-height: 1.6;
      white-space: normal; //使文本可以多行显示
      text-overflow: ellipsis; //使多余的部分用省略号来代替
      overflow: hidden; //隐藏多余的部分
      display: -webkit-box; //浮动布局
      -webkit-line-clamp: 2; //显示的行数
      -webkit-box-orient: vertical; //垂直排列
    }
    .time {
      color: #999;
      font-size: 14px;
    }
  }
}
</style>
